package com.android.butterknife;

import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.Editable;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
import android.widget.TextView;
import butterknife.Bind;
import butterknife.BindBool;
import butterknife.BindColor;
import butterknife.BindDimen;
import butterknife.BindDrawable;
import butterknife.BindInt;
import butterknife.BindString;
import butterknife.ButterKnife;
import butterknife.OnCheckedChanged;
import butterknife.OnEditorAction;
import butterknife.OnFocusChange;
import butterknife.OnTextChanged;
import butterknife.OnTextChanged.Callback;
import butterknife.OnTouch;

public class OtherActivity extends Activity {

	@BindDrawable(R.drawable.ic_launcher)
	Drawable mDrawable;
	@BindDimen(R.dimen.test_dimen)
	float dimen;
	@BindColor(R.color.common_color)
	int mColorValue;
	@BindBool(R.bool.test_bool)
	boolean mBooleanValue;
	@BindInt(R.integer.test_integer)
	int mIntValue;
	@BindString(R.string.app_name)
	String appName;
	@Bind(R.id.iv_logo)
	ImageView mIVLogo;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_other);
		ButterKnife.bind(this);

		Log.e("OtherActivity", "dimen:" + dimen);
		Log.e("OtherActivity", "mBooleanValue:" + mBooleanValue);
		Log.e("OtherActivity", "mIntValue:" + mIntValue);
		Log.e("OtherActivity", "appName:" + appName);
		mIVLogo.setBackgroundColor(mColorValue);
		mIVLogo.setImageDrawable(mDrawable);
	}

	@OnCheckedChanged(R.id.check)
	void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
		buttonView.setChecked(isChecked);
	}

	@OnTouch(R.id.iv_logo)
	boolean onTouch(View v, MotionEvent event) {
		if (event.getAction() == MotionEvent.ACTION_DOWN) {
			Log.e("OtherActivity", "onTouch--ACTION_DOWN");
		} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
			Log.e("OtherActivity", "onTouch--ACTION_MOVE");
		} else if (event.getAction() == MotionEvent.ACTION_UP) {
			Log.e("OtherActivity", "onTouch--ACTION_UP");
		}
		return true;
	}

	@OnEditorAction(R.id.edit_search)
	public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
		Log.e("OtherActivity", "onEditorAction() called");
		return false;
	}

	@OnFocusChange(R.id.edit_search)
	void OnFocusLChange(boolean b) {
		Log.e("OtherActivity", "OnFocusLChange--focus：" + b);
	}

	@OnTextChanged(value = R.id.edit_search, callback = Callback.AFTER_TEXT_CHANGED)
	void afterTextChanged(Editable s) {
		Log.e("OtherActivity", "afterTextChanged--Editable：" + s.toString());
	}

	@OnTextChanged(value = R.id.edit_search, callback = Callback.BEFORE_TEXT_CHANGED)
	void beforeTextChanged(CharSequence s, int start, int count, int after) {
		Log.e("OtherActivity",
				"beforeTextChanged--CharSequence：" + s.toString());
	}

	@OnTextChanged(value = R.id.edit_search, callback = Callback.TEXT_CHANGED)
	void onTextChanged(CharSequence s, int start, int before, int count) {
		Log.e("OtherActivity", "onTextChanged--CharSequence：" + s.toString());
	}

}
